<template>
  <el-config-provider :locale="zhCn" size="default" :z-index="1000">
    <router-view></router-view>
  </el-config-provider>
</template>

<script setup>
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import {sysMsgNotReadCount} from "@/common/api/system";
import layoutStore from "@/common/store/layoutStore";
import {getAccessToken} from "@/common/utils/cache";

const timer = ref()

onMounted(() => {
  nextTick(() => {
    getMsgCount()
    timer.value = setInterval(() => {
      getMsgCount()
    }, 10000);
  })
})

onBeforeUnmount(() => {
  clearInterval(timer.value);
})

// 查询系统消息
function getMsgCount() {

  if (getAccessToken()) {
    console.log("查询系统消息")
    sysMsgNotReadCount().then(res => {
      console.log(" 剩余未读消息 : ", res.data)
      if (res.data > 0) {
        layoutStore().notReadMsgCount = res.data;
      }
    })
  }

}
</script>

